import mongoose from '../dbHelper';
import { defaultSchemaExtend, defaultSchemaOptions } from "../config/index";

const Schema = mongoose.Schema;

const AiPayOrderSchema = new Schema(Object.assign({
    subject: { //   支付标题
        type: String,
        required: true
    },
    product_code: { // 支付产品
        type: String,
        required: false,
        default: 'FAST_INSTANT_TRADE_PAY'
    },
    total_amount: { // 支付金额
        type: Number,
        required: true
    },
    pay_type: { // 支付类型
        type: String,
        required: true
    },
    order_user_id: {
        type: Schema.Types.ObjectId,
        ref: 'AiUser'
    },
    order_shop_id: {
        type: Number
    },
    good_id: {
        type: Schema.Types.ObjectId,
        ref: 'DlyadminAigoods'
    },
    // 代理ID
    store_id: { // 
        type: Schema.Types.ObjectId,
        ref: 'DlyAdminUser'
    },
    notify_id: { // 
        type: String,
        required: false
    },
    // 支付时间
    gmt_create: {
        type: Date,
        required: false
    },
    trade_no: { // 支付宝交易号
        type: String,
        required: false
    },
    // 给的积分数量
    integral: {
        type: Number,
        required: false
    },
    // 送的积分
    send_integral: {
        type: Number,
        required: false
    },
    // 退款时间
    refund_time: {
        type: Date,
        required: false
    },
    status: {
        type: String,
        required: true,
        default: '0' // 0:未支付 1:已支付 2:已退款 3:已关闭
    },
    app_id: {
        type: String,
        required: false
    },
    // 支付时间
    gmt_payment: {
        type: Date,
        required: false
    },
    // 关闭时间
    gmt_close: {
        type: Date,
        required: false
    },
    buyerLogonId: { // 买家支付宝账号
        type: String,
        required: false
    },
    pay_html: { // 支付页面
        type: String,
        required: false

    },
    func_name: {
        type: String, // smsBuy 短信
        required: false
    },
    buy_sms_num: {
        type: Number, // 购买短信数量
        required: false
    },
    aavid: {
        type: String, // 广告账号
        required: false
    },
    use_qianchuan_status: { // 是否已经给千川的试用上了
        type: Boolean,
        required: false,
        default: false
    }
}, defaultSchemaExtend), defaultSchemaOptions);

const AiPayOrder = mongoose.model('AiPayOrder', AiPayOrderSchema, 'AiPayOrders');

export default AiPayOrder